package com.sc.study.clazz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sc.common.annotation.Log;
import com.sc.common.core.controller.BaseController;
import com.sc.common.core.domain.AjaxResult;
import com.sc.common.enums.BusinessType;
import com.sc.study.clazz.domain.ScClazzSubjectTeacher;
import com.sc.study.clazz.service.IScClazzSubjectTeacherService;
import com.sc.common.utils.poi.ExcelUtil;
import com.sc.common.core.page.TableDataInfo;

/**
 * 班级科目授权老师Controller
 * 
 * @author sc
 * @date 2022-02-27
 */
@RestController
@RequestMapping("/study/clazzsubjectteacher")
public class ScClazzSubjectTeacherController extends BaseController
{
    @Autowired
    private IScClazzSubjectTeacherService scClazzSubjectTeacherService;

    /**
     * 查询班级科目授权老师列表包含班级、科目、老师
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubjectteacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScClazzSubjectTeacher scClazzSubjectTeacher)
    {
        startPage();
        List<ScClazzSubjectTeacher> list = scClazzSubjectTeacherService.selectScClazzSubjectTeacherList(scClazzSubjectTeacher);
        return getDataTable(list);
    }

    /**
     * 导出班级科目授权老师列表
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubjectteacher:export')")
    @Log(title = "班级科目授权老师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScClazzSubjectTeacher scClazzSubjectTeacher)
    {
        List<ScClazzSubjectTeacher> list = scClazzSubjectTeacherService.selectScClazzSubjectTeacherList(scClazzSubjectTeacher);
        ExcelUtil<ScClazzSubjectTeacher> util = new ExcelUtil<ScClazzSubjectTeacher>(ScClazzSubjectTeacher.class);
        util.exportExcel(response, list, "班级科目授权老师数据");
    }

    /**
     * 获取班级科目授权老师详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubjectteacher:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scClazzSubjectTeacherService.selectScClazzSubjectTeacherById(id));
    }

    /**
     * 新增班级科目授权老师
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubjectteacher:add')")
    @Log(title = "班级科目授权老师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScClazzSubjectTeacher scClazzSubjectTeacher)
    {
        return toAjax(scClazzSubjectTeacherService.insertScClazzSubjectTeacher(scClazzSubjectTeacher));
    }

    /**
     * 修改班级科目授权老师
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubjectteacher:edit')")
    @Log(title = "班级科目授权老师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScClazzSubjectTeacher scClazzSubjectTeacher)
    {
        return toAjax(scClazzSubjectTeacherService.updateScClazzSubjectTeacher(scClazzSubjectTeacher));
    }

    /**
     * 删除班级科目授权老师
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubjectteacher:remove')")
    @Log(title = "班级科目授权老师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scClazzSubjectTeacherService.deleteScClazzSubjectTeacherByIds(ids));
    }
}
